export const BASE_CONFIG = {
    CHART_TYPES: {
        CUSTOM: 'custom',
        SQL: 'sql',
        SIGNATURE: 'signature'
    },

    MESSAGES: {
        // 成功消息
        ADD_SUCCESS: '添加成功',
        SAVE_SUCCESS: '保存成功',
        LOAD_SUCCESS: '加载成功',
        COPY_SUCCESS: '已复制！',

        // 错误消息
        LOAD_MODEL_FAILED: '加载模型失败',
        EXECUTE_FAILED: '执行失败',
        LOAD_CHART_FAILED: '加载图表失败',
        ADD_FAILED: '添加失败',
        SAVE_FAILED: '保存失败',
        LOAD_CHART_DATA_FAILED: '加载图表数据失败',
        COPY_FAILED: '复制失败，请手动复制',

        // 验证消息
        CHART_NAME_REQUIRED: '请输入图表名称',
        EXECUTE_CHART_REQUIRED: '请执行图表',
        NO_MODEL_SELECTED: '未选择任何执行器模型',
        UNKNOWN_NAME: '未知名称'
    },
    URLS: {
        INDEX: '/index.html',
        LAYOUT: '/src/page/layout/layout.html'
    }
};

export function mergeConfig(baseConfig, extensionConfig) {
    const merged = {};

    function deepMerge(target, source) {
        for (const key in source) {
            if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {
                target[key] = target[key] || {};
                deepMerge(target[key], source[key]);
            } else {
                target[key] = source[key];
            }
        }
        return target;
    }

    deepMerge(merged, baseConfig);
    deepMerge(merged, extensionConfig);

    return merged;
}

export function createConfig(extensionConfig = {}) {
    return mergeConfig(BASE_CONFIG, extensionConfig);
}